﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic;
using System.Text;
using System.Data;
using JXT.PrimaryKey.Batman.Extensions;
using JXT.PrimaryKey.Batman.Domain.Models;
using JXT.PrimaryKey.Batman.Domain.Specifications;
using JXT.PrimaryKey.Batman.Domain.UserSystem.Models;
using JXT.PrimaryKey.Batman.Domain.UserSystem.Repositories;
using JXT.PrimaryKey.Batman.Domain.Repositories.SqlServer.Expressions;

namespace JXT.PrimaryKey.Batman.Domain.Repositories.SqlServer.UserSystem
{
    public class SqlAuthorityTemplateRepository : SqlServerRepositoryBase<AuthorityTemplate, int>, IAuthorityTemplateRepository
    {
        public SqlAuthorityTemplateRepository(RepositoryContext context)
            : base((SqlServerRepositoryContext)context)
        {
        }

        protected override AuthorityTemplate ReadEntityFromDataReader(IDataReader dr)
        {
            AuthorityTemplate result = new AuthorityTemplate()
            {
                Id = dr.Read<int>("id"),
                Name = dr.Read<string>("name"),
                Summary = dr.Read<string>("summary")
            };
            try
            {
                result.Type = (AuthorityType)dr.Read<byte>("type");
                result.Priority = (PriorityType)dr.Read<byte>("priority");
            }
            catch
            {
#if DEBUG
                throw;
#endif
            }
            return result;
            //return base.ReadEntityFromDataReader(dr);
        }
    }
}
